package com.ibeeking.gmc.global.api.feign;

import com.ibeeking.gmc.global.api.common.query.AreaQuery;
import com.ibeeking.found.common.entity.AreaDTO;
import com.ibeeking.found.common.entity.DictDTO;
import com.ibeeking.gmc.global.api.feign.fallback.GlobalDictFeignFallbackFactory;
import com.ibeeking.nematos.utils.result.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;

/**
 * @Author ibeeking
 */
@FeignClient(name = "gmc-global-g-server", path = "/g", fallbackFactory = GlobalDictFeignFallbackFactory.class, decode404 = true)
public interface GlobalDictFeignClient {

    /* 全局字典 */

    /**
     * 批量获取字典列表
     *
     * @param dictTypes
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictByTypes")
    ResponseResult<List<DictDTO>> queryDictByTypes(@RequestBody String[] dictTypes);

    /**
     * 获取字典列表
     *
     * @param dictType
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictByType/{dictType}")
    ResponseResult<List<DictDTO>> queryDictByType(@PathVariable("dictType") String dictType);

    /**
     * 批量获取字典lable
     *
     * @param paramMap
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictLables")
    ResponseResult<List<DictDTO>> queryDictLables(@RequestBody Map<String, String> paramMap);

    /**
     * 获取字典lable
     *
     * @param dictType
     * @param dictValue
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictLable/{dictType}/{dictValue}")
    ResponseResult<DictDTO> queryDictLable(@PathVariable("dictType") String dictType, @PathVariable("dictValue") String dictValue);

    /* 中国地理区域 */

    /**
     * 根据编码查询名称
     *
     * @param code 地区编码
     * @return code
     */
    @PostMapping(value = "/area/feign/v1/queryName/{code}")
    ResponseResult<AreaDTO> queryName(@PathVariable("code") String code);

    /**
     * 根据编码查询名称
     *
     * @param codes 编码列表
     * @return 返回
     */
    @PostMapping(value = "/area/feign/v1/queryNames")
    ResponseResult<List<AreaDTO>> queryNames(@RequestBody List<String> codes);

    /**
     * 根据名称查询编码等信息
     *
     * @param areaQuery 名称列表
     * @return 返回
     */
    @PostMapping(value = "/area/feign/v1/queryArea")
    ResponseResult<List<AreaDTO>> queryArea(@RequestBody AreaQuery areaQuery);


    /**
     * 根据名称查询编码等信息
     *
     * @param parentCode 名称列表
     * @return 返回
     */
    @PostMapping(value = "/area/feign/v1/queryAreasByparentCode")
    ResponseResult<List<AreaDTO>> queryAreasByparentCode(@RequestBody String parentCode);


    /**
     * 根据id查询编码等信息
     *
     * @param id
     * @return 返回
     */
    @PostMapping(value = "/area/feign/v1/queryAreaName/{id}")
    ResponseResult<AreaDTO> queryAreaName(@PathVariable("id") @NotBlank(message = "id不能为空") Long id);

    /**
     * 根据codes查询所有下级编码等信息
     *
     * @param codes
     * @return 返回
     */
    @PostMapping(value = "/area/feign/v1/queryLowerAreasByCode/{flag}")
    ResponseResult<List<AreaDTO>> queryLowerAreasByCode(@RequestBody List<String> codes,@PathVariable("flag") Boolean flag);
}
